import {request} from "@/utils/service"
import type * as Login from "./types/login"
import _ from 'lodash'

/** 获取登录验证码 */
export function getLoginCodeApi() {
  return request<Login.LoginCodeResponseData>({
    url: "/user/login_code",
    method: "post"
  })
}

/** 登录并返回 Token */
export function loginApi(data: Login.LoginRequestData) {
  return request<Login.LoginResponseData>({
    url: "/user/login",
    method: "post",
    data
  })
}

/** 获取用户详情 */
export function getUserInfoApi() {
  return request<Login.UserInfoResponseData>({
    url: "/user/getInfo",
    method: "post"
  })
}

/**用户退出*/
export function logoutApi() {
  return request<Login.UserInfoResponseData>({
    url: "/user/logout",
    method: "post"
  })
}

export const updateUserSysConfig = _.debounce(data=> {
  return request({
    url: "/user/updateUserSysConfig",
    method: "post",
    data,
    showLoading: false,
  })
},500)
